Openspeech CTC Model

Openspeech CTC Model

class openspeech.models.openspeech_ctc_model.OpenspeechCTCModel(configs: omegaconf.dictconfig.DictConfig, tokenizer: openspeech.tokenizers.tokenizer.Tokenizer)[source]

Base class for OpenSpeech’s encoder-only models (ctc-model).

Parameters
  • configs (DictConfig) – configuration set.

  • tokenizer (Tokenizer) – tokenizer is in charge of preparing the inputs for a model.

Inputs:

inputs (torch.FloatTensor): A input sequence passed to encoders. Typically for inputs this will be a padded FloatTensor of size (batch, seq_length, dimension). input_lengths (torch.LongTensor): The length of input tensor. (batch)

Returns

Result of model predictions that contains y_hats, logits, output_lengths

Return type

ouputs (dict)

forward(inputs: torch.FloatTensor, input_lengths: torch.IntTensor) → Dict[str, torch.Tensor][source]

Forward propagate a inputs and targets pair for inference.

Parameters
  • inputs (torch.FloatTensor) – A input sequence passed to encoders. Typically for inputs this will be a padded FloatTensor of size (batch, seq_length, dimension).

  • input_lengths (torch.IntTensor) – The length of input tensor. (batch)

Returns

Result of model predictions that contains y_hats, logits, output_lengths

Return type

ouputs (dict)

set_beam_decoder(beam_size: int = 3)[source]

Setting beam search decoder

test_step(batch: tuple, batch_idx: int)collections.OrderedDict[source]

Forward propagate a inputs and targets pair for test.

Inputs:

train_batch (tuple): A train batch contains inputs, targets, input_lengths, target_lengths batch_idx (int): The index of batch

Returns

loss for training

Return type

loss (torch.Tensor)

training_step(batch: tuple, batch_idx: int)collections.OrderedDict[source]

Forward propagate a inputs and targets pair for training.

Inputs:

train_batch (tuple): A train batch contains inputs, targets, input_lengths, target_lengths batch_idx (int): The index of batch

Returns

loss for training

Return type

loss (torch.Tensor)

validation_step(batch: tuple, batch_idx: int)collections.OrderedDict[source]

Forward propagate a inputs and targets pair for validation.

Inputs:

train_batch (tuple): A train batch contains inputs, targets, input_lengths, target_lengths batch_idx (int): The index of batch

Returns

loss for training

Return type

loss (torch.Tensor)